<template>
	<el-dialog title="流程选择" v-model="visible" customClass="customWidth" destroy-on-close @closed="closeDialog">
		<el-container>
			<el-header>
				<div style="width: 40%;display: inline-block;padding:0 10px 0 10px">
					<el-form-item label="流水号" style="margin-bottom: 0">
						<el-input v-model="search.bpmRunNo" placeholder="流水号" clearable maxlength="80"></el-input>
					</el-form-item>
				</div>
				<div style="width: 40%;display: inline-block;padding:0 10px 0 10px">
					<el-form-item label="流程标题" prop="isTop" style="margin-bottom: 0">
						<el-input placeholder="流程标题" v-model="this.search.keyword" clearable></el-input>
					</el-form-item>
				</div>
				<div style="width: 10%;display: inline-block">
					<el-button type="primary" icon="el-icon-search" @click="upsearch"></el-button>
				</div>
			</el-header>
			<scTable ref="table" :params="search" :apiObj="apiObj" row-key="runId"  stripe remoteSort remoteFilter>
				<el-table-column label="选择" width="50" align="center">
					<template #default="scope">
						<el-radio v-model="selection" :label="scope.row.runId">{{""}}</el-radio>
					</template>
				</el-table-column>
				<el-table-column label="#" type="index" width="50"></el-table-column>
				<el-table-column label="流水号" prop="id" width="100"></el-table-column>
				<el-table-column label="流程名称" prop="flowTitle" width="200" :show-overflow-tooltip="true"></el-table-column>
				<el-table-column label="流程状态" prop="status" width="100">
					<template #default="scope">
						<el-tag v-if="scope.row.status=='1'" type="success">已结束</el-tag>
						<el-tag v-else type="waring">进行中</el-tag>
					</template>
				</el-table-column>
				<el-table-column label="创建人" prop="userName" width="100" :show-overflow-tooltip="true"></el-table-column>
				<el-table-column label="创建时间" prop="createTime" width="150" :show-overflow-tooltip="true"></el-table-column>
				<el-table-column label="操作" fixed="right" align="right">
					<template #default="scope">
						<el-button-group>
							<el-button text type="primary" size="small" @click="readBpmDetails(scope.row,scope.$index)">查看</el-button>
						</el-button-group>
					</template>
				</el-table-column>
			</scTable>
		</el-container>
		<template #footer>
			<el-button @click="visible=false">取 消</el-button>
			<el-button type="primary" :loading="isSaveing" @click="selectOk">确 定</el-button>
		</template>
	</el-dialog>
</template>
<script>
import scSelectFilter from '@/components/scSelectFilter'
export default {
	name: "Bpm Data Import Dialog",
	emits: ['success', 'closed'],
	components: {
		scSelectFilter,
	},
	props: {
		flowId: {type: String}
	},
	data() {
		return {
			visible: false,
			isSaveing: false,
			apiObj:this.$API.bpm.bpmList.getBpmListByFlowIdForSelect,
			search: {
				bpmRunNo:null,
				flowId:this.flowId,
				model:'0',
				keyword: null
			},
			selection: '',
		}
	},
	created() {
	},
	mounted() {
	},
	methods:{
		open() {
			this.visible = true;
			this.selection='';
			return this
		},
		async selectOk(){
			var res = await this.$API.bpm.bpmFormData.getFormDataForBpmImport.get({runId: this.selection, flowId: this.flowId});
			if (res.code == 200) {
				this.visible = false;
				this.$emit('success',res.data)
			} else {
				this.$alert(res.message, "提示", {type: 'error'})
			}

		},
		readBpmDetails(row,index)
		{
			this.$nextTick(() => {
				this.$router.replace({
					path: '/bpm/handle/read',
					query: {
						runId: row.runId
					}
				})
			})
		},
		//搜索
		async upsearch() {
			this.$refs.table.upData(this.search)
		},
	}
}
</script>
<style>
.customWidth {
	width: 50%;
}
:deep(.el-form-item)
{
	margin-bottom: 0px;
}
</style>
